#include<stdio.h>

#include"linklist.h"

static void show_int(const void *data);
void *list_reverse(listhead_t *list);

int main(void){
	listhead_t * list = NULL;
	listhead_init(&list, sizeof(int));
	int i;
	for(i = 1; i < 23; i+=2 ){
		list_insert(list, &i);
	}
	list_traval(list, show_int);
	printf("\n");
	list_reverse(list);
	list_traval(list, show_int);
	printf("\n");
	
	return 0;
}

static void show_int(const void *data)
{
	const int *d = (const int *)data;
	printf("%d ", *d);
}

void *list_reverse(listhead_t *list){
	struct node_st *p = list->head.next;
	struct node_st *cur = NULL;
	while(p->next != NULL){
		cur = p->next;
		p->next = cur->next;
		cur->next = list->head.next;
		list->head.next = cur;
	}
}
